﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HopeHealth.WebApp.Areas.Admin.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Admin/Default/

        public ActionResult Index()
        {
            if(Request.Cookies["admin"] == null)
            {
                return RedirectToAction("Login", "Home", new { area = "Admin" });
            }
            else
            {
                ViewBag.Admin = Request.Cookies["admin"].Value.ToString();
                return View();
            }
        }

        [HttpGet]
        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(string account, string password)
        {
            Response.Cookies.Add(new HttpCookie("admin", account));
            return RedirectToAction("Index", "Home", new { area = "Admin" });
        }
    }
}
